package com.tjetc.controller;

import com.tjetc.domain.RankRecord;
import com.tjetc.service.RankRecordService;
import com.tjetc.service.impl.RankRecordServiceImpl;
import com.tjetc.vo.HospitalBuildingInfoVo;
import com.tjetc.vo.RankDTO;
import com.tjetc.vo.Result;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * (rank_record)表控制层
 *
 * @author xxxxx
 */
@RestController
@RequestMapping("/rankRecord")
public class RankRecordController {
    /**
     * 服务对象
     */
    @Resource
    private RankRecordService rankRecordService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    public RankRecord selectOne(Integer id) {
        return rankRecordService.selectByPrimaryKey(id);
    }


    //获取所有的挂号记录
    @GetMapping("getAllRankRecord")
    public Result getAllRankRecord() {
        return rankRecordService.getAllRankRecord();
    }

    @GetMapping("getRank")
    public Result getRankVo(@RequestParam("id") Integer id) {
        return rankRecordService.getRankVos(id);
    }
    //获取医院楼栋信息
    @GetMapping("getHospitalBuilding")
    public Result getHospitalBuilding(@RequestParam("pid") Integer pid, @RequestParam("hospitalName") String hospitalName,@RequestParam("scheduleId") Integer scheduleId) {
        Result hospitalBuildingByPidAndHospitalName = rankRecordService.getHospitalBuildingByPidAndHospitalName(pid, hospitalName, scheduleId);
        System.out.println(hospitalBuildingByPidAndHospitalName);
        return hospitalBuildingByPidAndHospitalName;
    }
    //获取当前 ranks
    @RequestMapping("getMyRankRecord")
    public Result getMyRankRecord(@RequestParam("pid") Integer pid, @RequestParam("hospitalName") String hospitalName) {
        return rankRecordService.getMyRankRecord(pid, hospitalName);
    }
    //获取当前就诊的人是谁
    @RequestMapping("getCurrentcallnumber")
    public Result getCurrentcallnumber(@RequestParam("scheduleId") Integer scheduleId) {
        Result currentcallnumber = rankRecordService.getCurrentcallnumber(scheduleId);
        System.out.println(currentcallnumber);
        return currentcallnumber;
    }
    @PostMapping("rank")
    public Result rank(@RequestBody RankDTO rankDTO) {
        return rankRecordService.rank(rankDTO);
    }
    @GetMapping("cancelRank")
    public Result cancelRank(@RequestParam("rankId") Integer rankId, @RequestParam("hid") Integer hid) {
        return rankRecordService.cancelRank(rankId,hid);
    }

    @RequestMapping("getReportByRankId")
    public Result getReportByRankId(@RequestParam("pid") Integer pid) {
        return rankRecordService.getReportByRankId(pid);
    }

    @RequestMapping("getRankCount")
    public Result getRankCount(@RequestParam("hospitalName") String hospitalName) {
        return rankRecordService.getRankCount(hospitalName);
    }



    //根据分页信息,用户身份证号,用户名获取预约信息
    @GetMapping("getByNameAndPage")
    public Result getByNameAndPage(@RequestParam("idCard")String idCard,   @RequestParam("name")String name, @RequestParam("pageNum")Integer pageNum, @RequestParam("pageSize")Integer pageSize) {
        return rankRecordService.getByNameandPage(idCard, name, pageNum, pageSize);
    }
    @RequestMapping("payY")
    public Result payY(@RequestBody RankRecord rankRecord) {
        return rankRecordService.payY(rankRecord);
    }


    @GetMapping("getRankRecordsBySid")
    public Result getRankRecordsBySid(@RequestParam("sid") Integer sid) {
        return rankRecordService.getRankRecordsBySid(sid);
    }
    @GetMapping("jiaohao")
    public Result jiaohao(@RequestParam("sid") Integer sid ,@RequestParam("currentHao") Integer currentHao,@RequestParam("rid") Integer rid) {
        return rankRecordService.jiaohao(sid,currentHao, rid);
    }
    @GetMapping("zhenduan")
    public Result zhenduan(@RequestParam("rid") Integer rid) {
        return rankRecordService.zhenduan(rid);
    }
    @GetMapping("getHaoAndZhen")
    public Result getHaoAndZhen(@RequestParam("sid") Integer sid) {
        return rankRecordService.getHaoAndZhen(sid);
    }
    @GetMapping("jieshuzhenduan")
    public Result jieshuzhenduan(@RequestParam("sid") Integer sid,@RequestParam("currentZhen") Integer currentZhen,@RequestParam("result")String result) {
        return rankRecordService.jieshuzhenduan(sid,currentZhen,result);
    }

}
